<div id="content">
  <div class="row s_page_title">
    <sa-big-breadcrumbs
      [items]="['算法管理', '传感器状态明细']"
      icon="fa fa-subscript"
      class="col-xs-12 col-sm-7 col-md-7 col-lg-4"
    ></sa-big-breadcrumbs>
  </div>
  <sa-widgets-grid>
    <div class="s_table">
      <div sa-widget [editbutton]="false" color="darken" class="clearfix">
        <header>
          <span class="widget-icon"><i class="fa fa-table"></i></span>
          <h2>传感器状态明细</h2>
        </header>
        <div>
          <div class="widget-body no-padding">
            <div class="page-header clearfix s_table_opreation">
              <div class="left page-header-btn" style="width: calc(100% - 300px)">
                <sa-company-tree-car
                  companyTreeId="companyTree"
                  (companySelected)="companySelected($event)"
                ></sa-company-tree-car>
                <div class="top_module top_module_box">
                  <span class="top_module_label module_text">传感器状态</span>
                  <select name="" class="top_module_select" [(ngModel)]="sensorStatus">
                    <option value="">全部</option>
                    <option value="0">无损坏</option>
                    <option value="1">有损坏</option>
                  </select>
                </div>
                <div class="top_module top_module_box">
                  <span class="top_module_label module_text">线材状态</span>
                  <select name="" class="top_module_select" [(ngModel)]="lineStatus">
                    <option value="">全部</option>
                    <option value="0">无损坏</option>
                    <option value="1">有损坏</option>
                  </select>
                </div>
                <div class="top_module top_module_box">
                  <span class="top_module_label module_text">时间类型</span>
                  <select name="" class="top_module_select" [(ngModel)]="dateType">
                    <option value="startTime">数据开始时间</option>
                    <option value="createTime">创建时间</option>
                  </select>
                </div>
                <div class="selectDate top_module">
                  <table-select-date
                    [notInit]="false"
                    [initSelectDay]="initSelectDay"
                    (outerTime)="getSelectTableTime($event)"
                  ></table-select-date>
                </div>
                <button class="btn btn-primary" (click)="table_search()">查询</button>
                <button type="button" class="btn btn-primary" (click)="exportData()">导出</button>
              </div>
              <div class="right top-search">
                <input
                  type="text"
                  [(ngModel)]="searchKey"
                  (change)="table_search()"
                  class="search-input"
                  placeholder="车牌号、设备ID..."
                />
                <span class="top-search-box">
                  <button class="top-search-btn" type="button" (click)="table_search()">
                    <i class="fa fa-search"></i>
                  </button>
                </span>
              </div>
            </div>
            <div class="table_scroll">
              <table
                class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table"
              >
                <thead>
                  <tr>
                    <th>设备编码</th>
                    <th>车牌号码</th>
                    <th>数据开始时间</th>
                    <th>数据结束时间</th>
                    <th>线材损坏</th>
                    <th>线材平直</th>
                    <th>损坏通道</th>
                    <th>损坏明细</th>
                    <th>计算系数</th>
                    <th>在用系数</th>
                    <th>安装通道</th>
                    <th>创建时间</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody>
                  <tr
                    *ngFor="let row of tableData; let i = index"
                    [attr.data-index]="i"
                    [ngClass]="{ selected: activeSelected === row.id }"
                    (dblclick)="checkAbnormal(row)"
                  >
                    <td>{{ row.deviceId }}</td>
                    <td>{{ row.carNumber }}</td>
                    <td>{{ row.startTime }}</td>
                    <td>{{ row.endTime }}</td>
                    <td>
                      <span *ngIf="row.lineBad != 1"></span>
                      <span *ngIf="row.lineBad == 1">损坏</span>
                    </td>
                    <td>
                      <span *ngIf="row.lineAll == 1">整段平直</span>
                      <span *ngIf="row.lineAll != 1">
                        <span *ngIf="row.lineCount">{{ row.lineCount }}段平直</span>
                        <span *ngIf="!row.lineCount"></span>
                      </span>
                    </td>
                    <td>
                      <span
                        class="channel-style bg-red"
                        *ngFor="let item of row.sensorStatus; let index = index"
                        [style.display]="item != 1 && item != 2 && item != 3 && item != 4 ? 'none' : 'inline-block'"
                      >
                        {{ index + 1 }}
                      </span>
                    </td>

                    <td>
                      <span>
                        {{ row.sensorDamageDetail }}
                      </span>
                    </td>

                    <td>
                      <span *ngIf="row.coefT.length > 0">
                        <span>[</span>
                        <span *ngFor="let lis of row.coefT; let i = index">
                          <span style="font-weight: bold">CH{{ lis.index }}:</span>
                          <span>
                            {{ lis.value }}
                            <span *ngIf="i < row.coefT.length - 1">,</span>
                          </span>
                        </span>
                        <span>]</span>
                      </span>
                    </td>
                    <td>
                      <span *ngIf="row.currentCoefT.length > 0">
                        <span>[</span>
                        <span *ngFor="let lis of row.currentCoefT; let i = index">
                          <span style="font-weight: bold">CH{{ lis.index }}:</span>
                          <span>
                            {{ lis.value }}
                            <span *ngIf="i < row.currentCoefT.length - 1">,</span>
                          </span>
                        </span>
                        <span>]</span>
                      </span>
                    </td>
                    <td>
                      <span class="channel-style bg-green" *ngFor="let item of row.sensorChannel">{{ item }}</span>
                    </td>
                    <td>{{ row.createTime }}</td>
                    <td>
                      <button type="button" (click)="checkAbnormal(row)">查看</button>
                      <button type="button" (click)="delRow(row)">刪除</button>
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
            <div class="table-fix clearfix">
              <paginator
                [totalRecords]="totalCount"
                [rows]="pageSize"
                [currentPage]="curPage - 1"
                (onPageChange)="paginate($event)"
              ></paginator>
              <button type="button" class="btn default refresh_btn" (click)="refresh()">
                <i class="fa fa-refresh"></i>
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </sa-widgets-grid>
  <!--折线图-->
  <div style="background: white; border-radius: 5px; margin-top: 5px; position: relative" [hidden]="!isChartView">
    <button (click)="closeChart()" class="div_closeBtn">×</button>
    <div class="widget-body no-padding" style="margin: 0">
      <div class="page-header clearfix s_table_opreation" style="margin: 0">
        <div class="left page-header-btn" style="padding: 5px">
          <div class="top_module">
            <span class="module_text" style="background: none">异常数据折线图</span>
          </div>
          <div style="display: inline-block">
            <div>
              <div class="selectDate top_module">
                <table-select-date
                  [notInit]="true"
                  [specifyId]="specifyId"
                  [specifyTime]="specifyTime"
                  (outerTime)="getSelectChartTime($event)"
                ></table-select-date>
              </div>
              <button type="button" class="btn btn-primary" (click)="drawAbnormalChart()">查看</button>
            </div>
          </div>
        </div>
      </div>
    </div>

    <sa-chart-bmap
      [height]="325"
      [offDatas]="true"
      [inputParams]="selectedRow"
      [isBaiduMap]="true"
      (outerSend)="runParent($event)"
      (outerIsMap)="showMapView($event)"
      [isAuditData]="false"
      [isShowModify]="false"
    ></sa-chart-bmap>
    <div [hidden]="!isMapView">
      <sa-bmap-chart [trackParams]="drawTrackArr" [isShowBmap]="isMapView" deviceId="deviceId"></sa-bmap-chart>
    </div>
  </div>
</div>
